#ifndef _REACTOR_H_
#define _REACTOR_H_

#include <map>
#include <set>
#include <string>
#include <functional>
#include "thread.h"

class Event;
class Selector;
class SocketMGR;

//class ReactorBase
//{
//public:
//    virtual ~ReactorBase() {}
//};

class SocketReactor
    : public Runnable
{
public:
    SocketReactor(SocketMGR* mgr);
    virtual ~SocketReactor() {}

    virtual void Run() override;

    void Regist(Event* e);
    void Dispatch(const std::set<int>& keys);
    bool IsWork() const {return _is_work;}
private:
    SocketMGR* _sock_mgr {nullptr};
    Selector* _selector{nullptr};

    std::map<int, Event*> _events;

    bool _is_work {false};
};

#endif
